﻿using EmbeddedSharp.Core;

namespace Zove.Runtime.Core.Zoom {
    /// <summary>
    /// Zoom class parser factory
    /// </summary>
    public class ZoomClassParserFactory : IClassParserFactory {

        /// <summary>
        /// Language nature
        /// </summary>
        public ILanguageNature LanguageNature { get; private set; }

        /// <summary>
        /// Default constructor with language nature
        /// </summary>
        /// <param name="languageNature">language nature</param>
        public ZoomClassParserFactory(ILanguageNature languageNature)
        {
            LanguageNature = languageNature;
        }

        /// <summary>
        /// Create a zoom class parser
        /// </summary>
        /// <param name="provider">the content provider</param>
        /// <returns>a zoom class parser</returns>
        public IClassParser CreateClassParser(ITextContentProvider provider)
        {
            string source = provider.SourceReader.ReadToEnd();
            var lexer = new Lexer(source);
            var parser = new ZoomClassParser(lexer, LanguageNature);

            return parser;
        }
    }
}